package com.web.server;

import com.web.SpringUtils;
import com.web.server.db.DBUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@PropertySource(value = { "classpath:application.properties" })
public class TimerService {
    private final AsyncServer asyncServer = SpringUtils.getBean(AsyncServer.class);

    private final DBUtil dbUtil = new DBUtil();

    long task1Cnt = 0;

    @Scheduled(cron = "${sgw.topos.query.cron}")
    public void task1() {
        try {
            log.info("query topos task, {}", task1Cnt++);

            asyncServer.asyncTask();
        } catch (Exception e) {
            log.error("task1 request failed.{}", e.getMessage());

            Thread.currentThread().interrupt();
        }
    }
}
